﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.DataVisualization.Charting;

namespace BOMS.WebUI.Web.Warning
{
    public partial class WarningStatusChart : System.Web.UI.Page
    {
        
        public string EquipID
        {
            get { return Request.QueryString["equipid"]; }
        }
        public string HostName
        {
            get { return Request.QueryString["hostName"]; }
        }
        public string BatGrp
        {
            get { return Request.QueryString["batgrp"]; }
        }
        public int BatteryID
        {
            get
            {
                if (string.IsNullOrEmpty(Request.QueryString["batid"]))
                {
                    return -1;
                }
                else
                {
                    return int.Parse(Request.QueryString["batid"]);
                }
            }
        }
        public DateTime DtmBegin
        {
            get
            {
                if (!string.IsNullOrEmpty(Request.QueryString["dtmbegin"]))
                    return DateTime.Parse(Request.QueryString["dtmbegin"]);
                else
                    return new DateTime(2010, 1, 1);
            }
        }
        public DateTime DtmEnd
        {
            get
            {
                if (!string.IsNullOrEmpty(Request.QueryString["dtmend"]))
                    return DateTime.Parse(Request.QueryString["dtmend"]);
                else
                    return new DateTime(2030, 1, 1);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string winceName=HostName==""?" 所有主机":" 现场主机："+HostName;
            string group=BatGrp==""?"所有电池组":" 电池组："+BatGrp;
            string battery=BatteryID==-1?" 所有电池":" 电池："+BatteryID;
            string startTime=" 开始时间："+DtmBegin;
            string endTime=" 结束时间："+DtmEnd;
            this.LabelTitle.Text =winceName+group+battery+startTime+endTime+" 所有类型报警统计饼形图";
            BLL.S_Warning bll = new BLL.S_Warning();
            List<Model.WarningStatus> list = bll.GetWarningStatus(EquipID, BatGrp, BatteryID, DtmBegin, DtmEnd);

            System.Web.Script.Serialization.JavaScriptSerializer jsSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            this.JsonData1.Text = jsSerializer.Serialize(list);
        }
    }
}